<?php

use App\Http\Controllers\Api\AddressController;
use App\Http\Controllers\Api\ArticleController;
use App\Http\Controllers\Api\AuthorizationsController;
use App\Http\Controllers\Api\CategoryController;
use App\Http\Controllers\Api\ConfigController;
use App\Http\Controllers\Api\CustomerServiceController;
use App\Http\Controllers\Api\FeedbackController;
use App\Http\Controllers\Api\MaterialController;
use App\Http\Controllers\Api\MessageController;
use App\Http\Controllers\Api\OrderController;
use App\Http\Controllers\Api\PayController;
use App\Http\Controllers\Api\ProjectController;
use App\Http\Controllers\Api\SmsController;
use App\Http\Controllers\Api\UploadController;
use App\Http\Controllers\Api\UserController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
//登录获取token
Route::post('/authorizations', [AuthorizationsController::class, 'store']);

//文章-关于我们
Route::get('article/about', [ArticleController::class, 'about']);
//文章--常见问题
Route::get('articles', [ArticleController::class, 'index']);

Route::get('article', [ArticleController::class, 'article']);
//文章详情
Route::get('article/{article}', [ArticleController::class, 'show']);
//登录状态检测
Route::get('authorizations/check', [AuthorizationsController::class, 'check']);
//发送验证码
Route::get('sms', [SmsController::class, 'index']);

//网站配置
Route::get('config', [ConfigController::class, 'index']);

//上传图片
Route::post('upload', [UploadController::class, 'store']);
//意见反馈
Route::post('feedback', [FeedbackController::class, 'store']);
//客服
Route::get('customer-service', [CustomerServiceController::class, 'index']);
//注册
Route::post('user', [UserController::class, 'store']);
//忘记密码
Route::post('user/password', [UserController::class, 'password']);
//项目分类
Route::get('category', [CategoryController::class, 'index']);
//省市区
Route::get('address', [AddressController::class, 'index']);
//项目
Route::get('project', [ProjectController::class, 'index']);
Route::get('project/{id}', [ProjectController::class, 'show']);

//微信支付回调
Route::any('pay/wechat', [PayController::class, 'wechat']);
//支付宝回调
Route::any('pay/ali', [PayController::class, 'ali']);

//下载资料
Route::get('download', [MaterialController::class, 'download']);
Route::get('haha', [MaterialController::class, 'haha']);

Route::middleware('auth:api')->group(function () {
    //刷新token
    Route::put('authorizations', [AuthorizationsController::class, 'update']);
    //退出登录
    Route::delete('authorizations', [AuthorizationsController::class, 'destroy']);
    //获取用户信息
    Route::get('user', [UserController::class, 'index']);
    //修改个人信息
    Route::put('user', [UserController::class, 'edit']);
    //我的消息
    Route::get('message', [MessageController::class, 'index']);
    //阅读消息
    Route::put('message', [MessageController::class, 'edit']);
    //购买记录
    Route::get('order', [OrderController::class, 'index']);
    //购买
    Route::post('order', [OrderController::class, 'store']);
    //订单支付
    Route::get('order/pay', [OrderController::class, 'pay']);
    //支付查询
    Route::get('pay/check', [PayController::class, 'check']);
});
